package com.huike.clues.service.impl;

import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.ClueRecordMapper;
import com.huike.clues.service.ClueRecordService;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.utils.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
@RequiredArgsConstructor
public class ClueRecordServiceImpl implements ClueRecordService {
    private final ClueRecordMapper clueRecordMapper;

    @Override
    public void add(ClueTrackRecordVo tbClueTrackRecord) {
        tbClueTrackRecord.setType("0");
        tbClueTrackRecord.setCreateBy(SecurityUtils.getUsername());
        tbClueTrackRecord.setCreateTime(LocalDateTime.now());
        tbClueTrackRecord.setUpdateBy(SecurityUtils.getUsername());
        tbClueTrackRecord.setUpdateTime(LocalDateTime.now());
        clueRecordMapper.insert(tbClueTrackRecord);
    }

    @Override
    public TableDataInfo selectRecord(Long clueId) {
        List<ClueTrackRecordVo> recordVoList = clueRecordMapper.selectRecord(clueId);
        TableDataInfo tableDataInfo = new TableDataInfo(recordVoList, recordVoList.size());
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("查询成功");

        return tableDataInfo;
    }
}
